package com.abel.demo.es;

import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentFactory;

import java.io.IOException;

public class ESMapping {

    public static XContentBuilder catGameBuilder() throws IOException {
        XContentBuilder builder = XContentFactory.jsonBuilder();
        builder.startObject()
            .startObject("properties")

                .startObject("title")
                .field("type", "text")
                .field("analyzer", "ik_smart") //配置分词器
                .endObject()

                .startObject("env")
                .field("type", "keyword")
                .endObject()

                .startObject("catId")
                .field("type", "integer")
                .endObject()

                .startObject("gameId")
                .field("type", "integer")
                .endObject()

            .endObject()
        .endObject();

        return builder;
    }
}
